//拱猪

#include<stdio.h>
#include <string.h>

struct player
{
	char color[16];
	int number[16];
};

int calculate( struct player party , int numofcard );

int main()
{
	//变量区
	struct player party[4];
	int numofcard=0;
	int round=0;
	int judge[4]={1};
	int end=0;
	int sum[4]={0};
	int cadnum[4]={0};
	char c='\0';
	
	for ( int i=0 ; i<4 ; i++ )
	{
		for( int j=0 ; j<16 ; j++ )
		{
			party[i].number[j]=0;
		}
	}
	

	while ( end != -1)
	{
		//输入区
		for ( int i=0 ; i<4 ; i++ )
		{
			numofcard = 0;
			scanf("%d",&numofcard);
			if( numofcard == 0 )
			{
				judge[i]=0;
				numofcard=0;
				continue;
			}
			else 
			{
				cadnum[i]=numofcard;
				for ( int j=0 ; j<numofcard ; j++ )
				{
					c=getchar();
					party[i].color[j]=getchar();
					scanf("%d",&party[i].number[j]);
				}
				c=getchar();
			}
		}
		
		//判断区
		if( judge[0]==0 && judge[1]==0 && judge[2]==0 && judge[3]==0 )
		{
			end=-1;
			continue;
		}
		else
		{
			for( int k=0 ; k<4 ; k++ )
			{
				judge[k]=1;
			}
		}
		
		//计算区
		for ( int i=0 ; i<4 ; i++ )
		{
			sum[i]=calculate( party[i] , cadnum[i] );
		}
		
		//输出区
		for( int i=0 ; i<4 ; i++ )
		{
			if ( sum[i] > 0 )
			{
				printf("+%d",sum[i]);
			}
			else if ( sum[i] == 0 )
			{
				printf("%d",sum[i]);
			}
			else if( sum[i] < 0 )
			{
				printf("%d",sum[i]);
			}
			
			if( i<3 )
			{
				printf(" ");
			}
		}
		printf("\n");
		
		//清零区
		for ( int i=0 ; i<4 ; i++ )
		{
			for( int j=0 ; j<16 ; j++ )
			{
				party[i].number[j] = 0;
			}
		}
		
		for ( int i=0 ; i<4 ; i++ )
		{
			for ( int j=0 ; j<16 ; j++ )
			{
				party[i].color[j] = '\0';
			}
		}
		
		for ( int i=0 ; i<4 ; i++ )
		{
			cadnum[i]=0;
		}
		
		for( int i=0 ; i<4 ; i++ )
		{
			sum[i]=0;
		}
		
	}
	
	return 0;
}


int calculate( struct player party , int numofcard )
{
	int sum=0;
	int flag=0;
	int cs=0;
	int cd=0;
	int bonus=0;
	if( numofcard == 16 )
	{
		sum = 1000;
	}
	else
	{
		for ( int i=0 ; i<numofcard ; i++ )
		{
			//红桃的计算
			if( party.color[i]=='H')
			{
				if( party.number[i] == 1 )
				{
					sum = sum-50;
					flag++;
				}
				else if( party.number[i] == 2 )
				{
					sum = sum-2;
					flag++;
				}
				else if( party.number[i] == 3 )
				{
					sum = sum-3;
					flag++;
				}
				else if( party.number[i] == 4 )
				{
					sum = sum-4;
					flag++;
				}
				else if( party.number[i] == 5 )
				{
					sum = sum-5;
					flag++;
				}
				else if( party.number[i] == 6 )
				{
					sum = sum-6;
					flag++;
				}
				else if( party.number[i] == 7 )
				{
					sum = sum-7;
					flag++;
				}
				else if( party.number[i] == 8 )
				{
					sum = sum-8;
					flag++;
				}
				else if( party.number[i] == 9 )
				{
					sum = sum-9;
					flag++;
				}
				else if( party.number[i] == 10 )
				{
					sum = sum-10;
					flag++;
				}
				else if( party.number[i] == 11 )
				{
					sum = sum-20;
					flag++;
				}
				else if( party.number[i] == 12 )
				{
					sum = sum-30;
					flag++;
				}
				else if( party.number[i] == 13 )
				{
					sum = sum-40;
					flag++;
				}
				
			}
			
			//黑桃的计算
			if( party.color[i]=='S')
			{
				sum = sum-100;
				cs++;
			}
			
			//方片的计算
			if( party.color[i]=='D')
			{
				sum = sum+100;
				cd++;
			}
			
			//梅花的计算
			if( party.color[i]=='C')
			{
				bonus=1;
			}
			
			//特殊情况的计算
			if ( flag==13 && cd==0 && cs==0 )
			{
				sum = 200;
			}
			else if( flag==13 && cd==1 && cs==1 )
			{
				sum = 500;
			}
			else if( flag==13 && cd==1 && cs==0 )
			{
				sum = 300;
			}
			else if( flag==13 && cd==0 && cs==1 )
			{
				sum = 100;
			}
			
			
		}
		
		if( bonus==1 && cs + cd !=2 && numofcard>1 ) 
		{
			sum = sum*2;
		}
		else if( bonus==1 && numofcard==1 )
		{
			sum = 50;
		}
	}
	return sum;
}

